package com.wxdc.nmgyt.nmgytwydc.fragment;


import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.InfoWindow;
import com.baidu.mapapi.map.MapPoi;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.RouteLine;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.route.BikingRoutePlanOption;
import com.baidu.mapapi.search.route.BikingRouteResult;
import com.baidu.mapapi.search.route.DrivingRoutePlanOption;
import com.baidu.mapapi.search.route.DrivingRouteResult;
import com.baidu.mapapi.search.route.IndoorRouteResult;
import com.baidu.mapapi.search.route.MassTransitRouteResult;
import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener;
import com.baidu.mapapi.search.route.PlanNode;
import com.baidu.mapapi.search.route.RoutePlanSearch;
import com.baidu.mapapi.search.route.TransitRouteResult;
import com.baidu.mapapi.search.route.WalkingRoutePlanOption;
import com.baidu.mapapi.search.route.WalkingRouteResult;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.wxdc.nmgyt.nmgytwydc.R;
import com.wxdc.nmgyt.nmgytwydc.activity.WebActivity;
import com.wxdc.nmgyt.nmgytwydc.adapter.NavigationData_JzdInfo_RecyclerViewAdapter;
import com.wxdc.nmgyt.nmgytwydc.adapter.RouteLineAdapter;
import com.wxdc.nmgyt.nmgytwydc.app.MyApp;
import com.wxdc.nmgyt.nmgytwydc.common.BaiDuMapBasicSetup;
import com.wxdc.nmgyt.nmgytwydc.common.BaiduMapDrawGraph;
import com.wxdc.nmgyt.nmgytwydc.common.CoordinateConvert;
import com.wxdc.nmgyt.nmgytwydc.common.CustomDialog;
import com.wxdc.nmgyt.nmgytwydc.common.UpperCaseTransform;
import com.wxdc.nmgyt.nmgytwydc.greendao.JcdInfoBeanDao;
import com.wxdc.nmgyt.nmgytwydc.greendao.ope.JcdInfoBeanDaoOpe;
import com.wxdc.nmgyt.nmgytwydc.model.BASE_WORKFLOWCURRENT;
import com.wxdc.nmgyt.nmgytwydc.model.JcdInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.ValidateJcdInfoResultBean;
import com.wxdc.nmgyt.nmgytwydc.presenter.NavigationDataPersenter;
import com.wxdc.nmgyt.nmgytwydc.presenter.contract.NavigationDataContract;
import com.wxdc.nmgyt.nmgytwydc.utils.BikingRouteOverlay;
import com.wxdc.nmgyt.nmgytwydc.utils.DrivingRouteOverlay;
import com.wxdc.nmgyt.nmgytwydc.utils.Network;
import com.wxdc.nmgyt.nmgytwydc.utils.OverlayManager;
import com.wxdc.nmgyt.nmgytwydc.utils.SharedPreferenceUtil;
import com.wxdc.nmgyt.nmgytwydc.utils.WalkingRouteOverlay;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import okhttp3.ResponseBody;

import static android.content.Context.SENSOR_SERVICE;

/**
 * Created by Administrator on 2018/3/21.
 */

public class NavigationDataFragment extends BaseFragment<NavigationDataPersenter> implements NavigationDataContract.View, SwipeRefreshLayout.OnRefreshListener, SensorEventListener, OnGetRoutePlanResultListener {
    private final String TAG = this.getClass().getSimpleName();
    @BindView(R.id.data_collect_drawerLayout)
    DrawerLayout mDataCollectDrawerLayout;
    @BindView(R.id.left_menu)
    LinearLayout mLeftMenu;
    @BindView(R.id.toolbar_title)
    TextView mToolbarTitle;
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.swipe_refresh_layout)
    SwipeRefreshLayout mSwipeRefreshLayout;
    @BindView(R.id.recyclerview)
    RecyclerView mRecyclerview;
    @BindView(R.id.bmapView)
    MapView mBmapView;
    @BindView(R.id.fragment_data_map_loc_btn)
    ImageButton mFragmentDataMapLocBtn;
    @BindView(R.id.search_edit)
    EditText mSearchEdit;
    Unbinder unbinder;
    @BindView(R.id.fragment_data_map_routeplan_imgbtn)
    ImageButton mFragmentDataMapRouteplanImgbtn;
    @BindView(R.id.fragment_data_map_remove_route_imgbtn)
    ImageButton mFragmentDataMapRemoveRouteImgbtn;
    @BindView(R.id.route_car_imgcarbtn)
    ImageButton mRouteCarImgcarbtn;
    @BindView(R.id.route_car_imgwalkbtn)
    ImageButton mRouteCarImgwalkbtn;
    @BindView(R.id.route_car_imgbikebtn)
    ImageButton mRouteCarImgbikebtn;
    @BindView(R.id.map_routeplane_linelayout)
    LinearLayout mMapRouteplaneLinelayout;
    /* @BindView(R.id.fragment_data_map_addjcd_imgbtn)
     ImageButton mFragmentDataMapAddjcdImgbtn;*/
    private ActionBarDrawerToggle mDrawerToggle;
    private AppCompatActivity mActivity;
    private boolean mIsVisibleToUser;
    private MyApp mApp;
    private RxPermissions rxPermissions;
    private SensorManager mSensorManager;
    private BaiDuMapBasicSetup mMapBasicSetup;
    private BaiduMap mBaiduMap;
    private Location location;
    private final int GETLOCATIONSUCCESS = 0X101;
    private Message message;
    private Timer mTimer;
    private TimerTask mTimerTask;
    private boolean isOpenInfoWindow;
    private JcdInfoBean infoBean;
    // 搜索相关
    RoutePlanSearch mSearch = null;    // 搜索模块，也可去掉地图模块独立使用
    private LatLng curtLatLng, endLatLng;
    private RouteLine mRouteLine;
    private OverlayManager routeOverlay = null;
    ;

    private Handler mHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            switch (msg.what) {
                case GETLOCATIONSUCCESS:
                    mMapBasicSetup.initMap(location, rxPermissions);
                    break;
            }
            return false;
        }
    });

    @Override
    public int getmLayoutId() {
        return R.layout.fragment_data_collect;
    }

    @Override
    public void initInject() {
        getFragmentComponent().inject(this);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Log.i(TAG, "onAttach: -------------------------");
        message = Message.obtain();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mApp = MyApp.getInstance();
        mActivity = (AppCompatActivity) getActivity();
        rxPermissions = new RxPermissions(mActivity);
        mSensorManager = (SensorManager) mActivity.getSystemService(SENSOR_SERVICE);//获取传感器管理服务
        // Log.i(TAG, "onCreate: ---------------------------------");
        mJcdInfoBeanList = new ArrayList<>();

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Log.i(TAG, "onViewCreated: --------------------------");
        mToolbarTitle.setText("数据采集");
        if (mIsVisibleToUser) {
            customToolbar();
        }
        mBaiduMap = mBmapView.getMap();
        //隐藏地图上百度地图logo图标
        mBmapView.removeViewAt(1);
        mMapBasicSetup = new BaiDuMapBasicSetup(mActivity, mBaiduMap);
        initMap();

        //设置SwipeRefreshLayout
        mSwipeRefreshLayout.setOnRefreshListener(this);
        mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.paleturquoise));
        //设置RecyclerView
        mRecyclerview.setLayoutManager(new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false));
        //解决swipelayout与Recyclerview的冲突
        mRecyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                //计算Recyclerview第一个item的位置是否可见
                int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
                // Log.i(TAG, "onScrollStateChanged: -----------" + topRowVerticalPosition +"----------"+recyclerView.getChildCount()+"---------"+recyclerView.getChildAt(0).getTop());
                //当第一个item不可见时，设置SwipeRefreshLayout不可用
                mSwipeRefreshLayout.setClickable(topRowVerticalPosition == 0);

            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
            }
        });
        mSearchEdit.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String str = mSearchEdit.getText().toString().trim();
                mJcdInfoBeanList.clear();
                if (str.isEmpty()) {
                    Log.i(TAG, "onTextChanged: -------------------->empty");
                    if (SharedPreferenceUtil.getGzdwdm().equals("")) {
                        mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryAll(mContext));
                    } else {
                        mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryForUseridAndState(mContext, SharedPreferenceUtil.getGzdwdm()));
                    }
                } else {
                    Log.i(TAG, "onTextChanged: -------------------->not empty");
                    if (SharedPreferenceUtil.getGzdwdm().equals("")) {
                        mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryForFieldLike(mContext, str));
                    } else {
                        mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryForUseridLike(mContext, SharedPreferenceUtil.getGzdwdm(), str));
                    }
                }
                updateJcdInfoUI();
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
        //查询本地缓存的监测点数据
        mJcdInfoBeanList.clear();
        if (SharedPreferenceUtil.getGzdwdm().equals("")) {//游客登录状态
            mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryAll(mContext));
        } else {
            mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryForUseridAndState(mContext, SharedPreferenceUtil.getGzdwdm()));
        }
        //Log.i(TAG, "showJcdInfo: ------------使用本地数据显示界面");
        updateJcdInfoUI();
        // 初始化搜索模块，注册事件监听
        mSearch = RoutePlanSearch.newInstance();
        mSearch.setOnGetRoutePlanResultListener(this);
    }

    /*地图设置
    * */
    private boolean isFirstLocationMap;

    private void initMap() {
        isFirstLocationMap = true;
        location = mApp.getMyBinder() == null ? null : mApp.getMyBinder().getLocation();
        if (location != null) {
            isFirstLocationMap = false;
            mMapBasicSetup.initMap(location, rxPermissions);
        }
        startTimer();
        mFragmentDataMapLocBtn.setOnClickListener(mMapBasicSetup.new MyLocListener(location));
        mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {
                mBaiduMap.hideInfoWindow();
                isOpenInfoWindow = false;
            }

            @Override
            public boolean onMapPoiClick(MapPoi mapPoi) {
                return false;
            }
        });
        mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                Log.i(TAG, "onMarkerClick: ------------->" + marker.getExtraInfo());
                if (marker.getExtraInfo() == null) {
                    return false;
                }
                infoBean = (JcdInfoBean) marker.getExtraInfo().get("jczInfoObj");
                //生成一个View用户在地图中显示InfoWindow
                ConstraintLayout markerLayout = (ConstraintLayout) LayoutInflater.from(mContext).inflate(R.layout.baidu_infowindow, null);
                ViewHolder viewHolder = null;
                if (markerLayout.getTag() == null) {
                    viewHolder = new ViewHolder();
                    viewHolder.info_window_jcdname_txt = markerLayout.findViewById(R.id.info_window_jcdname_txt);
                    viewHolder.info_window_jcdtype_txt = markerLayout.findViewById(R.id.info_window_jcdtype_txt);
                    viewHolder.info_window_jd_txt = markerLayout.findViewById(R.id.info_window_jd_txt);
                    viewHolder.info_window_wd_txt = markerLayout.findViewById(R.id.info_window_wd_txt);
                    viewHolder.info_window_hb_txt = markerLayout.findViewById(R.id.info_window_hb_txt);
                    viewHolder.info_window_szxzq_txt = markerLayout.findViewById(R.id.info_window_szxzq_txt);
                    /*viewHolder.into_window_check_btn = markerLayout.findViewById(R.id.info_window_check_btn);*/
                    markerLayout.setTag(viewHolder);
                }
                viewHolder = (ViewHolder) markerLayout.getTag();
                viewHolder.info_window_jcdname_txt.setText(infoBean.getGEMNAME());
                viewHolder.info_window_jcdtype_txt.setText(infoBean.getGEMTYPE());
                viewHolder.info_window_jd_txt.setText(String.valueOf(infoBean.getJd()));
                viewHolder.info_window_wd_txt.setText(String.valueOf(infoBean.getWd()));
                viewHolder.info_window_hb_txt.setText(String.valueOf(infoBean.getHB()) + "米");
                viewHolder.info_window_szxzq_txt.setText(String.valueOf(infoBean.getXZQMC()));
                /*viewHolder.into_window_check_btn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //核查点反馈
                        checkPointFeedBack();
                    }
                });*/
                //初始化infowindow
                InfoWindow infoWindow = new InfoWindow(markerLayout, marker.getPosition(), -80);
                mBaiduMap.showInfoWindow(infoWindow);
                isOpenInfoWindow = true;
                //移动到当前点
                mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(marker.getPosition()));
                return false;
            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    //============================OnGetRoutePlanResultListener======================================
    @Override
    public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {
        Log.i(TAG, "onGetWalkingRouteResult: -------步行--------->" + walkingRouteResult);
        if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
            mApp.showToastLongMessage(mContext, "抱歉，未找到结果");
        }
        if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
            // 起终点或途经点地址有岐义，通过以下接口获取建议查询信息
            return;
        }
        if (walkingRouteResult.error == SearchResult.ERRORNO.NO_ERROR) {

            if (walkingRouteResult.getRouteLines().size() > 1) {
                if (!hasShownDialogue) {
                    myRouteDialog myTransitDlg = new myRouteDialog(mContext,
                            walkingRouteResult.getRouteLines(),
                            RouteLineAdapter.Type.WALKING_ROUTE);
                    myTransitDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            hasShownDialogue = false;
                        }
                    });
                    myTransitDlg.setOnItemInDlgClickLinster(new OnItemInDlgClickListener() {
                        public void onItemClick(int position) {
                            mRouteLine = walkingRouteResult.getRouteLines().get(position);
                            WalkingRouteOverlay overlay = new MyWalkingRouteOverlay(mBaiduMap);
                            mBaiduMap.setOnMarkerClickListener(overlay);
                            routeOverlay = overlay;
                            overlay.setData(walkingRouteResult.getRouteLines().get(position));
                            overlay.addToMap();
                            overlay.zoomToSpan();
                        }

                    });
                    myTransitDlg.show();
                    hasShownDialogue = true;
                }
            } else if (walkingRouteResult.getRouteLines().size() == 1) {
                // 直接显示
                mRouteLine = walkingRouteResult.getRouteLines().get(0);
                WalkingRouteOverlay overlay = new MyWalkingRouteOverlay(mBaiduMap);
                mBaiduMap.setOnMarkerClickListener(overlay);
                routeOverlay = overlay;
                overlay.setData(walkingRouteResult.getRouteLines().get(0));
                overlay.addToMap();
                overlay.zoomToSpan();

            } else {
                Log.d("route result", "结果数<0");
                return;
            }

        }
    }

    @Override
    public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) {

    }

    @Override
    public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) {

    }

    @Override
    public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
        Log.i(TAG, "onGetDrivingRouteResult: ------驾车-------->" + drivingRouteResult);
        if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
            mApp.showToastLongMessage(mContext, "抱歉，未找到结果");
        }
        if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
            // 起终点或途经点地址有岐义，通过以下接口获取建议查询信息
            // result.getSuggestAddrInfo()
            return;
        }
        if (drivingRouteResult.getRouteLines().size() > 1) {
            if (!hasShownDialogue) {
                myRouteDialog routeDialog = new myRouteDialog(mContext, drivingRouteResult.getRouteLines(), RouteLineAdapter.Type.DRIVING_ROUTE);
                routeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        hasShownDialogue = false;
                    }
                });
                routeDialog.setOnItemInDlgClickLinster(new OnItemInDlgClickListener() {
                    @Override
                    public void onItemClick(int position) {
                        mRouteLine = drivingRouteResult.getRouteLines().get(position);
                        DrivingRouteOverlay overlay = new MyDrivingRouteOverlay(mBaiduMap);
                        mBaiduMap.setOnMarkerClickListener(overlay);
                        routeOverlay = overlay;
                        overlay.setData(drivingRouteResult.getRouteLines().get(position));
                        overlay.addToMap();
                        overlay.zoomToSpan();
                    }
                });
                routeDialog.show();
                hasShownDialogue = true;
            }

        } else if (drivingRouteResult.getRouteLines().size() == 1) {
            mRouteLine = drivingRouteResult.getRouteLines().get(0);
            DrivingRouteOverlay overlay = new MyDrivingRouteOverlay(mBaiduMap);
            routeOverlay = overlay;
            mBaiduMap.setOnMarkerClickListener(overlay);
            overlay.setData(drivingRouteResult.getRouteLines().get(0));
            overlay.addToMap();
            overlay.zoomToSpan();
        } else {

        }
    }

    @Override
    public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) {

    }

    @Override
    public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) {
        Log.i(TAG, "onGetBikingRouteResult: ------------骑行--------->" + bikingRouteResult);
        if (bikingRouteResult == null || bikingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
            mApp.showToastLongMessage(mContext, "抱歉，未找到结果");
        }
        if (bikingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
            // 起终点或途经点地址有岐义，通过以下接口获取建议查询信息
            return;
        }
        if (bikingRouteResult.error == SearchResult.ERRORNO.NO_ERROR) {
            if (bikingRouteResult.getRouteLines().size() > 1) {
                if (!hasShownDialogue) {
                    myRouteDialog myTransitDlg = new myRouteDialog(mContext,
                            bikingRouteResult.getRouteLines(),
                            RouteLineAdapter.Type.DRIVING_ROUTE);
                    myTransitDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            hasShownDialogue = false;
                        }
                    });
                    myTransitDlg.setOnItemInDlgClickLinster(new OnItemInDlgClickListener() {
                        public void onItemClick(int position) {
                            mRouteLine = bikingRouteResult.getRouteLines().get(position);
                            BikingRouteOverlay overlay = new MyBikingRouteOverlay(mBaiduMap);
                            mBaiduMap.setOnMarkerClickListener(overlay);
                            routeOverlay = overlay;
                            overlay.setData(bikingRouteResult.getRouteLines().get(position));
                            overlay.addToMap();
                            overlay.zoomToSpan();
                        }

                    });
                    myTransitDlg.show();
                    hasShownDialogue = true;
                }
            } else if (bikingRouteResult.getRouteLines().size() == 1) {
                mRouteLine = bikingRouteResult.getRouteLines().get(0);
                BikingRouteOverlay overlay = new MyBikingRouteOverlay(mBaiduMap);
                routeOverlay = overlay;
                mBaiduMap.setOnMarkerClickListener(overlay);
                overlay.setData(bikingRouteResult.getRouteLines().get(0));
                overlay.addToMap();
                overlay.zoomToSpan();
            } else {
                Log.d("route result", "结果数<0");
                return;
            }

        }
    }

    //--------------------------------------------------------------------------------------------
    // 定制RouteOverly
    private class MyDrivingRouteOverlay extends DrivingRouteOverlay {

        public MyDrivingRouteOverlay(BaiduMap baiduMap) {
            super(baiduMap);
        }

        @Override
        public BitmapDescriptor getStartMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_st);
        }

        @Override
        public BitmapDescriptor getTerminalMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_en);
        }
    }

    private class MyWalkingRouteOverlay extends WalkingRouteOverlay {

        public MyWalkingRouteOverlay(BaiduMap baiduMap) {
            super(baiduMap);
        }

        @Override
        public BitmapDescriptor getStartMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_st);
        }

        @Override
        public BitmapDescriptor getTerminalMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_en);

        }
    }

    private class MyBikingRouteOverlay extends BikingRouteOverlay {
        public MyBikingRouteOverlay(BaiduMap baiduMap) {
            super(baiduMap);
        }

        @Override
        public BitmapDescriptor getStartMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_st);
        }

        @Override
        public BitmapDescriptor getTerminalMarker() {
            return BitmapDescriptorFactory.fromResource(R.drawable.icon_en);
        }


    }
    //==============================================================================================

    /**
     * 复用弹出面板markerLayout的控件
     */
    private class ViewHolder {
        TextView info_window_jcdname_txt;
        TextView info_window_jcdtype_txt;
        TextView info_window_jd_txt;
        TextView info_window_wd_txt;
        TextView info_window_hb_txt;
        TextView info_window_szxzq_txt;
        Button into_window_check_btn;
    }

    private void startTimer() {
        if (mTimer == null) {
            mTimer = new Timer();
        }
        if (mTimerTask == null) {
            mTimerTask = new TimerTask() {
                @Override
                public void run() {
                    location = mApp.getMyBinder().getLocation();
                    if (location != null && isFirstLocationMap) {
                        message.what = GETLOCATIONSUCCESS;
                        mHandler.sendMessage(message);
                        isFirstLocationMap = false;
                    }
                }
            };
        }
        if (mTimer != null && mTimerTask != null) {
            mTimer.schedule(mTimerTask, 0, 2 * 1000);
        }
    }

    private void stopTimer() {
        if (mTimer != null) {
            mTimer.cancel();
            mTimer = null;
        }
        if (mTimerTask != null) {
            mTimerTask.cancel();
            mTimerTask = null;
        }
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        mMapBasicSetup.setSensor(event);
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }

    /*
        * 自定义标题
        * */
    private void customToolbar() {
        //用toolbar代替actionbar
        // Log.i(TAG, "customToolbar: ----------------"+mActivity);
        mActivity.setSupportActionBar(mToolbar);
        //获取actionbar
        ActionBar actionBar = mActivity.getSupportActionBar();
        actionBar.setTitle("");
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        setHasOptionsMenu(true);
        mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDataCollectDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
            @Override
            public void onDrawerOpened(View drawerView) {
                // Log.i(TAG, "onDrawerOpened: ------------------");  //展开侧边栏时打开手势滑动
                //mDataCollectDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
               /*
                *此方法报java.lang.IllegalStateException: Fatal Exception thrown on Scheduler错误
                *
                if (!Network.isConnected(mContext)) {
                    return;
                } else {//如果在有网络的情况下，每次打开侧边栏更新一次监测点数据(用来获取最新已提交数据和未提交数据信息)
                    mCircleProgressDialog.showDialog();
                    mPersenter.getJcdInfo();//根据登陆token获得用户操作的监测点
                }*/
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                //Log.i(TAG, "onDrawerClosed: ---------------"); //合起侧边栏时关闭手势滑动
                //mDataCollectDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

            }
        };
        mDataCollectDrawerLayout.addDrawerListener(mDrawerToggle);//给DrawerLayout设置开关的监听
        mDrawerToggle.syncState();//实现toolbar和Drawer的联动
        //关闭手势滑动
        mDataCollectDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    /*
    * 实现该方法即可实现可见再加载。不可见不加载的效果！！！
    * */
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        mIsVisibleToUser = isVisibleToUser;
        //Log.i(TAG, "setUserVisibleHint: -----------------" + isVisibleToUser + "--------" + mIsVisibleToUser);
        if (mIsVisibleToUser && mActivity != null) {
            customToolbar();
        }
    }

    /*
    * optionMenu
    * */

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int selectID = item.getItemId();
        switch (selectID) {
            case android.R.id.home:
                if (mDataCollectDrawerLayout.isDrawerOpen(mLeftMenu)) {//判断内容是否可见
                    mDataCollectDrawerLayout.closeDrawer(mLeftMenu);//关闭
                } else {
                    mDataCollectDrawerLayout.openDrawer(mLeftMenu);//打开
                }
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @BindView(R.id.left_menu_point)
    Button mLeftMenuPoint;
    @BindView(R.id.left_menu_table)
    Button mLeftMenuTable;
    @BindView(R.id.left_menu_point_content)
    LinearLayout mLeftMenuPointContent;
    @BindView(R.id.left_menu_table_content)
    LinearLayout mLeftMenuTableContent;
    @BindView(R.id.left_menu_view01)
    View mLeftMenuView01;
    @BindView(R.id.left_menu_view02)
    View mLeftMenuView02;
    @BindView(R.id.left_menu_view03)
    View mLeftMenuView03;
    @BindView(R.id.left_menu_view04)
    View mLeftMenuView04;
    @BindView(R.id.left_menu_title1)
    Button mLeftMenuTitle1;

    // 设置起终点信息
    private PlanNode stNode, enNode;

    @OnClick({R.id.left_menu_point, R.id.left_menu_table, R.id.left_menu_title1, R.id.left_menu_title2, R.id.left_menu_title3,
            R.id.left_menu_title4, R.id.fragment_data_map_routeplan_imgbtn, R.id.fragment_data_map_remove_route_imgbtn,
            R.id.route_car_imgcarbtn, R.id.route_car_imgwalkbtn, R.id.route_car_imgbikebtn})
    public void onViewClicked(View view) {
        int colorYellow = Color.parseColor("#c0ffff00");
        int colorTransparent = Color.parseColor("#00000000");
        ColorDrawable drawableYellow = new ColorDrawable(colorYellow);
        ColorDrawable drawableTransparent = new ColorDrawable(colorTransparent);
        switch (view.getId()) {
            case R.id.left_menu_point:
                mLeftMenuPointContent.setVisibility(View.VISIBLE);
                mLeftMenuTableContent.setVisibility(View.GONE);
                mLeftMenuView01.setBackground(drawableYellow);
                mLeftMenuView02.setBackground(drawableTransparent);
                mLeftMenuView03.setBackground(drawableTransparent);
                mLeftMenuView04.setBackground(drawableYellow);
                break;
            case R.id.left_menu_table:
                mLeftMenuPointContent.setVisibility(View.GONE);
                mLeftMenuTableContent.setVisibility(View.VISIBLE);
                mLeftMenuView01.setBackground(drawableTransparent);
                mLeftMenuView02.setBackground(drawableYellow);
                mLeftMenuView03.setBackground(drawableYellow);
                mLeftMenuView04.setBackground(drawableTransparent);
                break;
            case R.id.left_menu_title1:
                if (isOpenInfoWindow) {
                    EventBus.getDefault().postSticky(infoBean);
                    //WebActivity.start(mActivity, mApp.getHTTPYd(), "ydinfo");
                    WebActivity.start(mActivity, "file:///android_asset/MobileT_Yd.html", "ydinfo");
                } else {
                    mApp.showToastLongMessage(mContext, "请先选中一个监测点");
                }
                break;
            case R.id.left_menu_title2:
                if (isOpenInfoWindow) {
                    EventBus.getDefault().postSticky(infoBean);
                    //WebActivity.start(mActivity, mApp.getHTTPCb(), "cbfzyf");
                    WebActivity.start(mActivity, "file:///android_asset/MobileT_Cb.html", "cbfzyf");
                } else {
                    mApp.showToastLongMessage(mContext, "请先选中一个监测点");
                }
                break;
            case R.id.left_menu_title3:
                if (isOpenInfoWindow) {
                    EventBus.getDefault().postSticky(infoBean);
                    //WebActivity.start(mActivity, mApp.getHTTPGm(), "gmfzyf");
                    WebActivity.start(mActivity, "file:///android_asset/MobileT_Gm.html", "gmfzyf");
                } else {
                    mApp.showToastLongMessage(mContext, "请先选中一个监测点");
                }
                break;
            case R.id.left_menu_title4:
                if (isOpenInfoWindow) {
                    EventBus.getDefault().postSticky(infoBean);
                    //WebActivity.start(mActivity, mApp.getHTTPPd(), "pdyf");
                    WebActivity.start(mActivity, "file:///android_asset/MobileT_Pd.html", "pdyf");
                } else {
                    mApp.showToastLongMessage(mContext, "请先选中一个监测点");
                }
                break;
            case R.id.fragment_data_map_routeplan_imgbtn://路径规划按钮点击事件
                if (location != null) {
                    curtLatLng = CoordinateConvert.getInstance().latLngConVert(new LatLng(location.getLatitude(), location.getLongitude()));
                }
                if (curtLatLng == null) {
                    mApp.showToastLongMessage(mContext, "暂未获取当前位置");
                    return;
                }
                if (endLatLng == null) {
                    mApp.showToastLongMessage(mContext, "请确定监测点位置");
                    return;
                }

                mMapRouteplaneLinelayout.setVisibility(View.VISIBLE);
                mFragmentDataMapRemoveRouteImgbtn.setVisibility(View.VISIBLE);
                break;
            case R.id.fragment_data_map_remove_route_imgbtn://清除规划路线
                mMapRouteplaneLinelayout.setVisibility(View.GONE);
                mFragmentDataMapRemoveRouteImgbtn.setVisibility(View.GONE);
                if (routeOverlay != null) {
                    routeOverlay.removeFromMap();
                }
                break;
            case R.id.route_car_imgcarbtn://驾车方式路线规划
                mRouteCarImgcarbtn.setBackgroundResource(R.drawable.route_car_text);
                mRouteCarImgwalkbtn.setBackgroundResource(R.drawable.route_walk);
                mRouteCarImgbikebtn.setBackgroundResource(R.drawable.route_bike);
                if (routeOverlay != null) {
                    routeOverlay.removeFromMap();
                }
                mSearch.drivingSearch((new DrivingRoutePlanOption())
                        .from(PlanNode.withLocation(curtLatLng)).to(PlanNode.withLocation(endLatLng)));
                break;
            case R.id.route_car_imgwalkbtn://步行方式路线规划
                mRouteCarImgwalkbtn.setBackgroundResource(R.drawable.route_walk_text);
                mRouteCarImgcarbtn.setBackgroundResource(R.drawable.route_car);
                mRouteCarImgbikebtn.setBackgroundResource(R.drawable.route_bike);
                if (routeOverlay != null) {
                    routeOverlay.removeFromMap();
                }
                mSearch.walkingSearch((new WalkingRoutePlanOption()).from(PlanNode.withLocation(curtLatLng)).to(PlanNode.withLocation(endLatLng)));
                break;
            case R.id.route_car_imgbikebtn://骑行方式路线规划
                mRouteCarImgbikebtn.setBackgroundResource(R.drawable.route_bike_text);
                mRouteCarImgcarbtn.setBackgroundResource(R.drawable.route_car);
                mRouteCarImgwalkbtn.setBackgroundResource(R.drawable.route_walk);
                if (routeOverlay != null) {
                    routeOverlay.removeFromMap();
                }
                mSearch.bikingSearch((new BikingRoutePlanOption()).from(PlanNode.withLocation(curtLatLng)).to(PlanNode.withLocation(endLatLng)));
                break;
           /* case R.id.fragment_data_map_addjcd_imgbtn://新增监测点
                addJcdFunction();
                break;*/
        }

    }

    /*
    * 核查点信息反馈
    * */
    private AlertDialog checkDialog;
    private CustomDialog feedBackHintDialog;

    private void checkPointFeedBack() {
        View view = LayoutInflater.from(mContext).inflate(R.layout.info_window_feedback_item, null);
        EditText feedBackEtxt = view.findViewById(R.id.feedback_info_etxt);
        checkDialog = new AlertDialog.Builder(mContext)
                .setMessage("反馈信息")
                .setView(view)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (checkDialog != null) {
                            checkDialog.dismiss();
                        }
                    }
                })
                .setPositiveButton("提交", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if ("".equals(feedBackEtxt.getText().toString().trim())) {
                            mApp.showToastLongMessage(mContext, "反馈内容不能为空");
                            return;
                        }
                        infoBean.setRemark(feedBackEtxt.getText().toString().trim());
                        mApp.showToastLongMessage(mContext, feedBackEtxt.getText().toString());
                        if (feedBackHintDialog == null) {
                            feedBackHintDialog = new CustomDialog(mContext, "正在提交...");
                        }
                        mPersenter.commitFeedBackInfo(infoBean);
                        Log.i(TAG, "onClick: ------------核查点反馈数据-------->" + infoBean);
                        if (checkDialog != null) {
                            checkDialog.dismiss();
                        }
                    }
                })
                .create();

        checkDialog.show();

    }

    /*
    * 生命周期
    * */
    @Override
    public void onResume() {
        super.onResume();
        mBmapView.onResume();
        //为系统的方向传感器注册监听器
        mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
                SensorManager.SENSOR_DELAY_UI);
    }

    @Override
    public void onPause() {
        super.onPause();
        mBmapView.onPause();
    }

    @Override
    public void onStop() {
        super.onStop();
        //取消注册传感器监听
        mSensorManager.unregisterListener(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mActivity = null;
        mViewAdapter = null;
        if (mSearch != null) {
            mSearch.destroy();
        }
        // 关闭定位图层
        if (mBmapView != null) {
            mBmapView.onDestroy();
        }
        if (mBaiduMap != null) {
            mBaiduMap.setMyLocationEnabled(false);
        }
        stopTimer();

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    /*
    * 实现SwipeRefreshLayout.OnRefreshListener事件的onRefresh方法
    *   下拉刷新
    * */
    @Override
    public void onRefresh() {
        if (!Network.isConnected(mContext)) {
            mApp.showToastLongMessage(mContext, getResources().getString(R.string.no_network));
            mSwipeRefreshLayout.setRefreshing(false);
            return;
        }
        mPersenter.getJcdInfo();//根据登陆token获得用户操作的监测点
    }

    @Override
    public void showYdInfo() {

    }

    private List<JcdInfoBean> mJcdInfoBeanList;//存储监测站信息

    /**
     * 查询当前用户所有的监测点
     *
     * @param jcdInfoBeans
     */
    @Override
    public void showJcdInfo(List<JcdInfoBean> jcdInfoBeans) {
        this.mJcdInfoBeanList.clear();
        this.mJcdInfoBeanList.addAll(jcdInfoBeans);
        mPersenter.findAuditData(2);
    }

    /**
     * @param responseBody 向服务器提交样地反馈信息----返回方法
     */
    @Override
    public void acceptCommitFeedBackInfoResult(ResponseBody responseBody) {
        if (feedBackHintDialog != null) {
            feedBackHintDialog.hideDialog();
        }
        //将该监测点信息状态标记为：已反馈状态
        // infoBean.setState(1);
        JcdInfoBeanDaoOpe.updateData(mContext, infoBean);
        //查询本地缓存的监测点数据
        mJcdInfoBeanList.clear();
        mJcdInfoBeanList.addAll(JcdInfoBeanDaoOpe.queryForUseridAndState(mContext, SharedPreferenceUtil.getGzdwdm()));
        //Log.i(TAG, "showJcdInfo: ------------使用本地数据显示界面");
        updateJcdInfoUI();
        mBaiduMap.clear();
    }

    /**
     * 待审和退回的数据
     *
     * @param results
     */
    @Override
    public void getBackOrWaitAuditDataResult(List<BASE_WORKFLOWCURRENT> results) {

    }

    /**
     * 审核完成的数据
     *
     * @param results
     */
    @Override
    public void getPassAuditDataResult(List<BASE_WORKFLOWCURRENT> results) {

    }

    /**
     * @param results
     */
    @Override
    public void getAuditDataResult(List<BASE_WORKFLOWCURRENT> results) {
        int dataLen = results.size();
        int jcdNums = mJcdInfoBeanList.size();
        if (dataLen != 0) {
            for (int i = 0; i < dataLen; i++) {
                if (results.get(i).getSAMPLEPLOTID() != null) {
                    for (int j = 0; j < jcdNums; j++) {
                        if (mJcdInfoBeanList.get(j).getGEMNAME().equals(results.get(i).getGEMNAME())) {
                            mJcdInfoBeanList.get(j).setAuditFlag(1);
                        }
                    }
                }
            }
        }
        if (jcdNums > 0) {//检测该样地信息今年是否已经采集
            curtIndex = 0;
            mPersenter.validateIsYdInfo(mJcdInfoBeanList.get(curtIndex).getGEMPOINTID());
            mTempListData = new ArrayList<>();
        }
    }

    /**
     * 检测该样地信息今年是否已经采集 返回结果
     *
     * @param obj
     */
    private int curtIndex;
    private List<JcdInfoBean> mTempListData;

    @Override
    public void getYdInfoValidateResult(ValidateJcdInfoResultBean obj) {
        JcdInfoBean mjcdObj = mJcdInfoBeanList.get(curtIndex);
        if ("200".equals(obj.getCode()) && !obj.getReRows().equals("0")) {//已采集数据
            if (mjcdObj.getAuditFlag() != 1) {
                mjcdObj.setAuditFlag(2);
            }
        }
        mTempListData.add(mjcdObj);
        curtIndex++;
        if (curtIndex < mJcdInfoBeanList.size()) {
            mPersenter.validateIsYdInfo(mJcdInfoBeanList.get(curtIndex).getGEMPOINTID());
        } else {
            mJcdInfoBeanList.clear();
            mJcdInfoBeanList.addAll(mTempListData);
            int len = mJcdInfoBeanList.size();
            for (int i = 0; i < len; i++) {
                mJcdInfoBeanList.get(i).setGzdmdm(SharedPreferenceUtil.getGzdwdm());
            }
            JcdInfoBeanDaoOpe.deleteInTx(mContext, JcdInfoBeanDaoOpe.queryForGzdwdm(mContext, SharedPreferenceUtil.getGzdwdm()));
            JcdInfoBeanDaoOpe.insertData(mContext, mJcdInfoBeanList);
            updateJcdInfoUI();
        }
        mCircleProgressDialog.dismiss();
    }

    //--------------------------------------------------------------------
    private NavigationData_JzdInfo_RecyclerViewAdapter mViewAdapter;

    /*
    * 更新监测点UI
    * */
    private void updateJcdInfoUI() {
        endLatLng = null;
        if (mViewAdapter == null) {
            // Log.i(TAG, "updateJcdInfoUI: ---------------if");
            mViewAdapter = new NavigationData_JzdInfo_RecyclerViewAdapter(mActivity, mJcdInfoBeanList);
            mRecyclerview.setAdapter(mViewAdapter);
            mViewAdapter.setItemClickListener(new NavigationData_JzdInfo_RecyclerViewAdapter.RecycleViewOnItemClickListener() {
                @Override
                public void onItemClick(int position) {
                    JcdInfoBean obj = mJcdInfoBeanList.get(position);
                    if (obj != null) {
                        double jd = obj.getJd();
                        double wd = obj.getWd();
                        endLatLng = CoordinateConvert.getInstance().latLngConVert(new LatLng(wd, jd));
                        BaiduMapDrawGraph.getInstance().drawMarkerToMap(mBaiduMap, obj);
                    }
                }
            });
        } else {
            mViewAdapter.notifyDataSetChanged();
            //   Log.i(TAG, "updateJcdInfoUI: -----------else");
        }
        // Log.i(TAG, "updateJcdInfoUI: ---------------------" + mJcdInfoBeanList.size() + "-----" + mViewAdapter + "----------" + mJcdInfoBeanList);
        mSwipeRefreshLayout.setRefreshing(false);
    }


    @Override
    public void showError(String msg) {
        mApp.showToastLongMessage(mActivity, msg);
        if (mSwipeRefreshLayout != null) {
            mSwipeRefreshLayout.setRefreshing(false);
        }
        hideProgressDialog();
    }

    //==============================================================================================
    // 响应DLg中的List item 点击
    interface OnItemInDlgClickListener {
        public void onItemClick(int position);
    }

    boolean hasShownDialogue = false;

    class myRouteDialog extends Dialog {

        private List<? extends RouteLine> mRouteLines;
        private ListView transitRouteList;
        private RouteLineAdapter mTransitAdapter;
        OnItemInDlgClickListener mOnItemInDlgClickListener;

        public myRouteDialog(@NonNull Context context, List<? extends RouteLine> routeLines, RouteLineAdapter.Type type) {
            super(context);
            mRouteLines = routeLines;
            mTransitAdapter = new RouteLineAdapter(context, routeLines, type);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
        }

        @Override
        public void setOnDismissListener(@Nullable OnDismissListener listener) {
            super.setOnDismissListener(listener);
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_transit_dialog);
            transitRouteList = findViewById(R.id.transitList);
            transitRouteList.setAdapter(mTransitAdapter);
            transitRouteList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    mOnItemInDlgClickListener.onItemClick(position);
                    dismiss();
                    hasShownDialogue = false;
                }
            });
        }

        public void setOnItemInDlgClickLinster(OnItemInDlgClickListener onItemInDlgClickLinster) {
            mOnItemInDlgClickListener = onItemInDlgClickLinster;
        }

    }

    //============新增监测点========================================================================
    private AlertDialog addDialog;

    private void addJcdFunction() {
        if (location == null) {
            mApp.showToastLongMessage(mContext, "无法获取当前位置信息");
            return;
        }
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.addjcd_dialog_item, null);
        EditText jcdmc_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdmc_etxt);
        EditText jcdmcsx_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdmcsx_etxt);
        EditText jcdtype_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdtype_etxt);
        EditText jcdjd_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdjd_etxt);
        EditText jcdwd_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdwd_etxt);
        EditText jcdhb_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdhb_etxt);
        EditText jcdszxzqh_etxt = dialogView.findViewById(R.id.addjcd_dialog_item_jcdszxzq_etxt);
        jcdmcsx_etxt.setTransformationMethod(new UpperCaseTransform());//小写字母自动转换为大写
        jcdjd_etxt.setText(String.valueOf(location.getLongitude()));//经度
        jcdwd_etxt.setText(String.valueOf(location.getLatitude()));//纬度
        jcdhb_etxt.setText(String.valueOf(location.getAltitude()));//海拔
        addDialog = new AlertDialog.Builder(mContext)
                .setTitle("新增监测点")
                .setView(dialogView)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        JcdInfoBean addJcdBean = new JcdInfoBean();
                        addJcdBean.setGEMNAME(jcdmc_etxt.getText().toString().trim());
                        addJcdBean.setGEMNAMESX(jcdmcsx_etxt.getText().toString().trim().toUpperCase());
                        addJcdBean.setGEMTYPE(jcdtype_etxt.getText().toString().trim());
                        String[] jd = CoordinateConvert.getInstance().DecimalToDegree(Double.valueOf(jcdjd_etxt.getText().toString().trim()));
                        String[] wd = CoordinateConvert.getInstance().DecimalToDegree(Double.valueOf(jcdwd_etxt.getText().toString().trim()));
                        addJcdBean.setJDD(jd[0]);
                        addJcdBean.setJDF(jd[1]);
                        addJcdBean.setJDM(jd[2]);
                        addJcdBean.setWDD(wd[0]);
                        addJcdBean.setWDF(wd[1]);
                        addJcdBean.setWDM(wd[2]);
                        addJcdBean.setHB((int) Double.parseDouble(jcdhb_etxt.getText().toString().trim()));
                        addJcdBean.setXZQMC(jcdszxzqh_etxt.getText().toString().trim());
                        // addJcdBean.setState(2);//表示新增
                        Log.i(TAG, "onClick: ---------新增监测点------>" + jcdmcsx_etxt.getText().toString().trim().toUpperCase() + "----" + addJcdBean);
                    }
                })
                .create();
        addDialog.show();
    }

}
